#include <iostream>
#include <stdlib.h>
#include <string>

#include "atlbase.h"
#include "atlstr.h"
#include "comutil.h"

using namespace std;

wchar_t* Convert(char *orig1)
{
    // Convert to a wchar_t*
    size_t origsize = strlen(orig1) + 1;
    const size_t newsize = 100;
    size_t convertedChars = 0;
    wchar_t* wcstring = (wchar_t *)malloc(origsize);
    mbstowcs_s(&convertedChars, wcstring, origsize, orig1, _TRUNCATE);
	return wcstring;
}

char * Convert2(wchar_t *WStr)
{
	size_t len = wcslen(WStr) + 1;
	size_t converted = 0;
	char *CStr;
	CStr=(char*)malloc(len*sizeof(char));
	wcstombs_s(&converted, CStr, len, WStr, _TRUNCATE);
	return CStr;
}

int main() 
{ 
	char *abc = "Hello";
	wcout << Convert(abc)<<endl;
	cout<<Convert2(Convert(abc))<<endl;
	return 0; 
} 
